<% include("../public/commonheader.html"){}%><!-- 配置文件 -->

<div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <label for="L_name" class="layui-form-label">
                            <span class="x-red">*</span>${L.appname}</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_name" name="name" lay-verify="required" autocomplete="off" class="layui-input">
						</div>
					</div>
                    <div class="layui-form-item">
                        <label for="L_url" class="layui-form-label">
                            <span class="x-red">*</span>${L.appurl}</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_url" name="url" required="" lay-verify="url" autocomplete="off" class="layui-input"></div>
                    </div>
					<div class="layui-form-item">
                        <label for="L_authkey" class="layui-form-label">
                            <span class="x-red">*</span>${L.appaukey}</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_authkey" name="authkey" lay-verify="required" autocomplete="off" class="layui-input"></div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_ip" class="layui-form-label">
                            <span class="x-red">*</span>${L.appip}</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_ip" name="ip" required="" lay-verify="ip" autocomplete="off" class="layui-input">
						</div>

					 </div>
					 <div class="layui-form-item">
                        <label for="L_allowips" class="layui-form-label">
                            <span class="x-red"></span>${L.appallowips}</label>
                        <div class="layui-input-block">
                           <textarea name="allowips"  class="layui-textarea"></textarea>
                         </div>
					 </div>
					 <div class="layui-form-item">
                        <label for="L_description" class="layui-form-label">
                            <span class="x-red"></span>${L.appdescription}</label>
                        <div class="layui-input-block">
                           <textarea id="container" name="description"  class="layui-textarea"></textarea>
                        </div>
					 </div>

                    <div class="layui-form-item">
                        <label for="L_submit" class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="add" lay-submit="">提交</button>
				    </div>
                </form>
            </div>
        </div>

<% include("../public/commonfooter.html"){}%>
<script>
layui.use(['form', 'layer','jquery'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;

                //自定义验证规则
                form.verify({
                    username: function(value) {
                        if (value.length < 3) {
                            return '用户名至少得3个字符';
                        }
                    },
                    password: [/(.+){6,12}$/, '密码必须6到12位'],
                    repass: function(value) {
                        if ($('#L_password').val() != $('#L_repass').val()) {
                            return '两次密码不一致';
                        }
                    }
                });

                //监听提交
                form.on('submit(add)',
                function(data) {
					$.post(jkas.url("/admin/applications/add"),data.field,function(result)
					{
                     if(200==result.code)
					 {
                    //发异步，把数据提交给php
                      layer.alert("增加成功", {
                        icon: 6
                      },
                      function() {
                        //关闭当前frame
                        Sca.close();

                        // 可以对父窗口进行刷新 
                        Sca.father_reload();
                      });
					  }
					  else
					  { layer.alert("操作失败 "+result.msg, {
                        icon: 5
                        });
					  }
				   },"json");
                    return false;
                });

            });
</script>
